import { SAVE_USER_INFO, DELETE_USER_INFO } from '../constan';

let user = JSON.parse(localStorage.getItem('user') || '{}')
let isLogin = localStorage.getItem('isLogin')

let initState = {
  user: user || {},
  isLogin: isLogin || false
}
export default function test (preState = initState, action) {
  const { type, data } = action;
  switch (type) {
    case SAVE_USER_INFO:
      return { user: data, isLogin: true };
    case DELETE_USER_INFO:
      return { user: '', isLogin: false };
    default:
      return preState
  }
}